import React from 'react';
import {HashRouter as Router, Switch, Route, Redirect} from 'react-router-dom'

import Main from './layout/main'
import Login from './views/Login'
import {connect} from "react-redux";

const App = ({isLogin}) => {
  return (
      <Router>
        <Switch>
          <Route path='/login' component={Login}/>
          {
            isLogin ? <Route path='/' component={Main}/>
            : <Redirect to='/login' />
          }
        </Switch>
      </Router>
  )
}

export default connect(
    state=> {
      return {
        isLogin: state.getIn(['user', 'isLogin'])
      }
    }
)(App);
